﻿@using OPM
@using OPM.Class;
@using System.Web.Mvc;
@using OPM.ServiceOfficer
@using OPM.MultiResource

@{
    var News = WSO.GetNews(U.Token);
    var Notifs = WSO.GetNotifies(U.Token);
    int NewsCount = News.Count();
    int NotifsCount = Notifs.Count();
    
}

<link rel="stylesheet" type="text/css" href="~/js/colorbox-master/colorbox.css">
<script src="~/js/colorbox-master/jquery.colorbox-min.js"></script>
<script>

    function callcolorbox(link) {
        $.colorbox({
            iframe: true,
            width: "650px",
            height: "95%",
            fastIframe: false,
            href: link
        });
    }

    function callboxNoti() {
        var step = 0;
        var limitPage = timelinePerPage - 1;
        $(".timeLineZone div").remove('.clear');
        checkLoadTimeline = false;
        $('.timeLineZone .timeLineBox:hidden').each(function (i, item) {
            var blockid = $(this).attr('data-id');

           @* $.get("@Url.Action("Index","Timeline")", { id: blockid })*@
            $.get("~/ViewCase/GroupList", { id: blockid })
                    .done(function (data) {
                        $(".timeLineBox[data-id='" + blockid + "']").html(data).show().find("time.timeago").timeago();

                        if (step == limitPage) {
                            masonry();

                        } else {
                            step++;
                        }
                    });
            if (i >= limitPage) {
                return false;
            }
        });
    }

    function callboxMes(link) {
        $.colorbox({
            iframe: true,
            width: "450px",
            height: "70%",
            fastIframe: false,
            href: link
        });
    }
    var resetPass = false;
    var resetUrl = "";
    function callcolorboxprofile(link) {
        $.colorbox({
            iframe: true,
            width: "650px",
            height: "95%",
            href: link,
            fastIframe: false,
            onClosed: function () {
                if (resetPass) {
                    $.colorbox({
                        iframe: true,
                        width: "650px",
                        height: "300px",
                        fastIframe: false,
                        href: resetUrl
                    });
                    resetPass = false;
                }
            }
        });

        console.log(resetPass);
        console.log(resetUrl);
    }


    function searchResult() {

        var keyword = $("search_form").val();
        alert(keyword);

        $.ajax({
            type: "POST",
            url: '/Search/Index',
            data: keyword,
            success: success,
            dataType: dataType
        });

    }
    function callcolorboxResetPass(link) {
        resetPass = true;
        resetUrl = link;
        console.log(resetPass);
        console.log(resetUrl);
        $.colorbox.close();
    }

</script>
<div class="top_menu w100p" @*onclick="javascript: window.location = '@Url.Action("Index", "Timeline")';"*@ title="@Multi.TimeLineString" style="cursor:pointer">
    <img src="~/images/logo.png" class="main-logo floatL" alt="" />
    <form action="@Url.Action("Index", "Search")" name="search_form" id="search_form" method="post" >
        <input class="search-box floatL" type="search" name="keyword_str" />
       @* <a href="@Url.Action("Index", "Search")">*@
        <input type="submit" name="search_submit" class="dNone" />@*</a>*@
    </form>
    <img src="~/images/search-icon.png" class="search-icon floatL" alt="" />
    <div class="floatR action-icon-bar">
        <div style="float: right;">
            @*@System.Threading.Thread.CurrentThread.CurrentCulture.Name (Session=@Session["culture"]) <a href="@Url.Action("ChangeLanguage", "Home")">Change</a>*@
        </div>
        <div class="action-icon action-icon1 p-Relative floatR">
           <div ></div>
            @*<div class="p-Absolute action-icon-notify"></div>*@
            <div class="p-Absolute action-icon-staus dNone editprofile-tab">
                <div class="action-icon-staus-triangle"></div>
                <div class="action-icon-staus-inner">
                    <a href="@Url.Action("Profile", "OfficerProfileLogs")?a=profile" onclick="callcolorboxprofile($(this).attr('href'));">
                        <span class="dBlock editprofile1">แก้ข้อมูลส่วนตัว</span>
                    </a>
                    <a href="#" onclick="window.location.href='@Url.Action("Logoff", "Account")'">
                        <span class="dBlock editprofile2">ออกจากระบบ</span>
                    </a>
                </div>
            </div>
        </div>
        <div class="action-icon action-icon2 p-Relative floatR">
            @if (NotifsCount > 0)
            {
                <div class="p-Absolute action-icon-notify"> @Notifs.Count() </div>
            }else{ <div></div> }
                                                     
            <div class="p-Absolute action-icon-staus dNone">
                <div class="action-icon-staus-triangle"></div>
                <div class="action-icon-staus-inner">
                    <div class="notify-tab">
                        @foreach (var noti in Notifs)
                        {
                            <a href="@Url.Action("ViewCase", "GroupList")?a=noti&id=@noti.case_id " onclick="window.location.href = $(this).attr('href')">
                                <span>
                                    <p><strong>เรื่อง : </strong>@noti.case_type_text</p>
                                    <p><strong>@Multi.Objective_text : </strong>@noti.case_objecve_text</p>
                                    <p><strong>@Multi.summary : </strong>@noti.summary</p>
                                    <p><strong>@Multi.status_text : </strong>@noti.case_status_text</p>
                                </span>
                            </a>
                        }
                    </div>
                    <div class="notify-tab-all">
                        ดูการแจ้งเตือนทั้งหมด
			            	<div class="notify-tab-More"></div>
                    </div>
                </div> 
            </div>
        </div>
        <div class="action-icon action-icon3 p-Relative floatR">
            @if (NewsCount > 0){
            <div class="p-Absolute action-icon-notify">@News.Count()}</div>
            }else{
                <div></div>
            }
            <div class="p-Absolute action-icon-staus dNone">
                <div class="action-icon-staus-triangle"></div>
                <div class="action-icon-staus-inner">

                    @foreach (var r in News)
                    {
                        <a href="@Url.Action("Detail", "Message")?a=prifile&id=@r.id" data-block="prifile" class="callBox" onclick="callboxMes($(this).attr('href'));">
                            @r.title_th
                        </a>
                    }

                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>



